package fr.pud.client.controller.bubble;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;

import fr.pud.client.i18n.LanguagesConstants;
import fr.pud.client.images.ImagesDatabase;
import fr.pud.client.view.JMapViewerExtended;
import fr.pud.client.view.mapstation.Bubble;
import fr.pud.client.view.mapstation.BubbleSubBackground;

/**
 * The action class for the bubble close operation
 * @author Pierre Reliquet
 */
public class CloseBubble extends AbstractAction {
    private static final long serialVersionUID = 1541642006807860054L;

    /**
     * Defaut constructor <br/>
     * Sets the name and the tooltip
     */
    public CloseBubble() {
        this.putValue(Action.NAME,
                LanguagesConstants.LANGUAGE.getString("Close"));
        this.putValue(SMALL_ICON, ImagesDatabase.VALIDATE);
        this.putValue(Action.SHORT_DESCRIPTION, LanguagesConstants.LANGUAGE
                .getObject(LanguagesConstants.CLOSE_DESCRIPTION));
    }

    /**
     * If pressed, the action hides the bubble
     */
    @Override
    public void actionPerformed(ActionEvent arg0) {
        JMapViewerExtended.getJMapViewer().setMapMarkerVisible(true);
        JMapViewerExtended.getJMapViewer().moveMap(0, 1);
        Bubble.getBubble(BubbleSubBackground.CENTER_SUB_BUBBLE).setVisible(
                false);
    }
}
